/**
 * 汽车之家登录js
 */
if (!window.XMLHttpRequest) {
	window.XMLHttpRequest = function() {
		var a = [ "MSXML2.XMLHTTP.4.0", "MSXML2.XMLHTTP.3.0",
				"MSXML2.XMLHTTP.2.6", "Msxml2.XMLHTTP", "Microsoft.XMLHTTP",
				"MSXML.XMLHTTP" ];
		for (var c = 0; c < a.length; c++) {
			try {
				return new ActiveXObject(a[c])
			} catch (b) {
			}
		}
		return null
	}
}
Function.createDelegate = function(a, b) {
	return function() {
		return b.apply(a, arguments)
	}
};
if (typeof Autohome == "undefined") {
	var Autohome = {}
}
if (!Autohome.exetend) {
	Autohome.exetend = function(b, a) {
		for ( var c in a) {
			b[c] = a[c]
		}
		return b
	}
}
Autohome.Ajax = function(a, c, b) {
	this.options = Autohome.exetend({
		_xmlHttpRequest : new XMLHttpRequest(),
		url : "",
		body : "",
		backFun : function() {
			return null
		},
		method : "POST"
	}, a || {});
	if (c && b) {
		this.options.body = c;
		this.options.backFun = b;
		this.options.url = a
	}
	this.send = function() {
		this.options._xmlHttpRequest.open(this.options.method,
				this.options.url, true);
		this.options._xmlHttpRequest.setRequestHeader("Content-Type",
				"application/x-www-form-urlencoded; charset=UTF-8");
		this.options._xmlHttpRequest.onreadystatechange = Function
				.createDelegate(this, this._completed);
		this.options._xmlHttpRequest.send(this.FormatBody())
	};
	this.FormatBody = function() {
		var d = "";
		for ( var e in this.options.body) {
			d += e + "=" + escape(this.options.body[e]) + "&"
		}
		return d
	};
	this._completed = function() {
		if (this.options._xmlHttpRequest.readyState == 4) {
			this.options.backFun(this.options._xmlHttpRequest.responseText,
					this.options._xmlHttpRequest)
		}
	};
	this.send()
};
function $(a) {
	return typeof (a) == "string" ? document.getElementById(a) : a
}
var Msg = {
	UserNameNull : "账号不能为空",
	PassWordNull : "密码不能为空",
	AccountError : "帐号或密码错误，请点击上方忘记密码找回。",
	ValidateCodeNull : "验证码不能为空",
	ValidateCodeLengthError : "验证码不正确",
	AdminError : "",
	Success : ""
};
var onfocusClass = "";
var onblurClass = "";
var uc = 0;
var pc = 0;
function CheckUser() {
	var domain = window.location.host;
	switch (domain) {
	case "account.autohome.com.cn":
		onfocusClass = "lgpt-focus";
		onblurClass = "lgpt";
		break;
	case "account.che168.com":
		onfocusClass = "txt_lgn1";
		onblurClass = "txt_lgn";
		break;
	default:
		break
	}
	$("UserName").onfocus = function() {
		$("UserName").className = onfocusClass
	};
	$("UserName").onblur = function() {
		$("UserName").className = onblurClass
	};
	$("UserName").onkeyup = function() {
		uc = uc + 1;
		var ul = 0;
		var pl = 0;
		if ($("UserName").value != undefined) {
			ul = $("UserName").value.length
		}
		if ($("PassWord").value != undefined) {
			pl = $("PassWord").value.length
		}
		setCookie("_SYLMM", uc + "-" + ul + "-" + pc + "-" + pl)
	};
	$("PassWord").onkeyup = function() {
		pc = pc + 1;
		var ul = 0;
		var pl = 0;
		if ($("UserName").value != undefined) {
			ul = $("UserName").value.length
		}
		if ($("PassWord").value != undefined) {
			pl = $("PassWord").value.length
		}
		setCookie("_SYLMM", uc + "-" + ul + "-" + pc + "-" + pl)
	};
	$("PassWord").onfocus = function() {
		$("PassWord").className = onfocusClass
	};
	$("PassWord").onblur = function() {
		$("PassWord").className = onblurClass
	};
	$("PassWord").onkeypress = function(event) {
		event = (event) ? event : ((window.event) ? window.event : "");
		keyCode = event.keyCode ? event.keyCode : (event.which ? event.which
				: event.charCode);
		if (keyCode == 13) {
			$("SubmitLogin").onclick()
		}
	};
	if ($("validateCode")) {
		$("validateCode").onfocus = function() {
			$("validateCode").className = onfocusClass
		};
		$("validateCode").onblur = function() {
			$("validateCode").className = onblurClass
		};
		$("validateCode").onkeypress = function(event) {
			event = (event) ? event : ((window.event) ? window.event : "");
			keyCode = event.keyCode ? event.keyCode
					: (event.which ? event.which : event.charCode);
			if (keyCode == 13) {
				$("SubmitLogin").onclick()
			}
		}
	}
	$("SubmitLogin").onclick = function() {
		var isCheck = 0;
		var UserName = $("UserName");
		var PassWordPr = $("PassWordPr");
		PassWordPr.innerHTML = "";
		if (UserName.value == "") {
			PassWordPr.innerHTML = "账号不能为空";
			$("UserName").className = onfocusClass;
			setCursort(UserName);
			isCheck = 1
		}
		if (isCheck == 0) {
			var PassWord = $("PassWord");
			if (PassWord.value == "") {
				PassWordPr.innerHTML = "密码不能为空";
				$("PassWord").className = onfocusClass;
				isCheck = 1;
				setCursort(PassWord)
			} else {
				if (PassWord.value.length < 6 || PassWord.value.length > 40) {
					PassWordPr.innerHTML = "账号或密码错误";
					$("UserName").className = onfocusClass;
					isCheck = 1;
					setCursort(PassWord)
				}
			}
		}
		var validateCodeValue = "";
		if (isCheck == 0 && $("td1code").style.display != "none") {
			var validateCode = $("validateCode");
			validateCodeValue = validateCode.value;
			if (validateCodeValue == "") {
				PassWordPr.innerHTML = "验证码不能为空";
				validateCode.className = onfocusClass;
				setCursort(validateCode);
				isCheck = 1
			} else {
				if (validateCodeValue.length != 4) {
					PassWordPr.innerHTML = "验证码不正确";
					validateCode.className = onfocusClass;
					setCursort(validateCode);
					isCheck = 1
				}
			}
		}
		if (isCheck == 0) {
			var IsAuto = $("IsAutoLogin").checked;
			new Autohome.Ajax(
					{
						_self : this,
						url : "/Login/ValidIndex",
						body : {
							name : encodeURIComponent(UserName.value.replace(
									/\+/gi, "%2B")),
							pwd : hex_md5(PassWord.value),
							validcode : validateCodeValue,
							isauto : IsAuto,
							type : "json",
							backurl : $("backUrl").value,
							url : $("url").value
						},
						backFun : function(Text) {
							var o = eval("(" + Text + ")");
							if (o == undefined) {
								alert("系统出了问题，请联系客服！")
							}
							if (o.success == 0) {
								if (o.Msg == "Msg.AdminError") {
									window.location = "login/adminindex?isauto="
											+ IsAuto
											+ "&backurl="
											+ $("backUrl").value;
									return
								}
								if (o.Msg == "Msg.ChangePassword") {
									window.location = "login/UpdatePassWordIndex?isauto="
											+ IsAuto
											+ "&backurl="
											+ $("backUrl").value;
									return
								}
								isAddCodeDiv(eval(o.Msg));
								PassWordPr.innerHTML = eval(o.Msg);
								$("PassWord").className = onfocusClass;
								if ($("validateCode")) {
									$("validateCode").className = onfocusClass
								} else {
									setCursort($("UserName"))
								}
							} else {
								if (o.Msg == "Msg.ChangePassword") {
									$("backUrl").value = "http://i.autohome.com.cn/setting/password"
								}
								JsLoad(o.LoginUrl);
								setCookie("_SYLMM", "")
							}
						}
					})
		}
	}
}
function JLoad(c) {
	var d = document.createElement("script");
	var a = false;
	d.setAttribute("type", "text/javascript");
	d.setAttribute("src", c);
	d.onload = d.onreadystatechange = function() {
		if (!a
				&& (!this.readyState || this.readyState == "loaded" || this.readyState == "complete")) {
			a = true;
			try {
				d.parentNode.removeChild(d)
			} catch (b) {
			}
		}
	};
	document.getElementsByTagName("head")[0].appendChild(d)
}
function JsLoad(c) {
	var e = document.createElement("script");
	var a = false;
	e.setAttribute("type", "text/javascript");
	e.setAttribute("src", c);
	e.onload = e.onreadystatechange = function() {
		if (!a
				&& (!this.readyState || this.readyState == "loaded" || this.readyState == "complete")) {
			a = true;
			try {
				e.parentNode.removeChild(e)
			} catch (b) {
			}
		}
	};
	document.getElementsByTagName("head")[0].appendChild(e);
	var f = 0;
	var d = setInterval(function() {
		if (a == true || f == 2) {
			clearTimeout(d);
			setTimeout("Sccuess('" + $("url").value + "','"
					+ $("backUrl").value + "')", 0)
		}
		f = f + 1
	}, 1000);
	return a
}
function Sccuess(a, b) {
	if (b != null && b != undefined && b != "") {
		a = decodeURIComponent(b)
	} else {
		if (a != null && a != "") {
			a = decodeURIComponent(a)
		} else {
			a = $("hostUrl").value
		}
	}
	window.location.href = a
}
function getCursortPosition(c) {
	var b = 0;
	if (document.selection) {
		c.focus();
		var a = document.selection.createRange();
		a.moveStart("character", -c.value.length);
		b = a.text.length
	} else {
		if (c.selectionStart || c.selectionStart == "0") {
			b = c.selectionStart
		}
	}
	return (b)
}
function setCaretPosition(b, c) {
	if (b.setSelectionRange) {
		b.focus();
		b.setSelectionRange(c, c)
	} else {
		if (b.createTextRange) {
			var a = b.createTextRange();
			a.collapse(true);
			a.moveEnd("character", c);
			a.moveStart("character", c);
			a.select()
		}
	}
}
function SetUserName() {
	var b = document.cookie.split("; ");
	name = "clubUserShow";
	for (var c = 0; c < b.length; c++) {
		var a = b[c].split("=");
		if (name == a[0]) {
			if (a.length > 1) {
				setCursort($("PassWord"));
				var d = decodeURIComponent(a[1]).split("|");
				$("UserName").value = d.length > 5 ? d[3] : "";
				return
			}
		}
	}
}
function setCursort(b) {
	var a = getCursortPosition(b);
	setCaretPosition(b, a)
}
CheckUser();
function RequestFrs() {
	var d = "fr";
	var b = document.location.href;
	var f = b.indexOf("?");
	var e = b.substr(f + 1);
	var c = e.split("&");
	for (var a = 0; a < c.length; a++) {
		var g = c[a].split("=");
		if (g[0].toUpperCase() == d.toUpperCase()) {
			return g[1]
		}
	}
	return ""
}
var str = RequestFrs();
if (str != "sina") {
	SetUserName()
}
function isAddCodeDiv(a) {
	host = window.location.host;
	if (a != null && a.indexOf("验证码") > -1) {
		document.getElementById("td1code").style.display = "";
		document.getElementById("ValidateCodeimg").onclick()
	} else {
		new Autohome.Ajax(
				{
					_self : this,
					url : "/ValidateCode/AddValidateCode",
					body : {},
					backFun : function(b) {
						if (b == "1") {
							document.getElementById("td1code").style.display = "";
							if (host != undefined && host != null && host != "") {
								if (host.indexOf(".che168.com") >= 0) {
									document.getElementById("td2code").style.display = ""
								}
							}
							document.getElementById("ValidateCodeimg")
									.onclick()
						} else {
							document.getElementById("td1code").style.display = "none";
							if (host != undefined && host != null && host != "") {
								if (host.indexOf(".che168.com") >= 0) {
									document.getElementById("td2code").style.display = "none"
								}
							}
						}
						document.getElementById("validateCode").value = ""
					}
				})
	}
}
isAddCodeDiv();
function getimg() {
	$("ValidateCodeimg").src = "/ValidateCode/GetValidateCode?id="
			+ Math.random()
}
function setCookie(a, b) {
	document.cookie = a + "=" + escape(b)
}
var hexcase = 0;
var b64pad = "";
var chrsz = 8;
function hex_md5(a) {
	return binl2hex(core_md5(str2binl(a), a.length * chrsz))
}
function b64_md5(a) {
	return binl2b64(core_md5(str2binl(a), a.length * chrsz))
}
function hex_hmac_md5(a, b) {
	return binl2hex(core_hmac_md5(a, b))
}
function b64_hmac_md5(a, b) {
	return binl2b64(core_hmac_md5(a, b))
}
function calcMD5(a) {
	return binl2hex(core_md5(str2binl(a), a.length * chrsz))
}
function md5_vm_test() {
	return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72"
}
function core_md5(p, k) {
	p[k >> 5] |= 128 << ((k) % 32);
	p[(((k + 64) >>> 9) << 4) + 14] = k;
	var o = 1732584193;
	var n = -271733879;
	var m = -1732584194;
	var l = 271733878;
	for (var g = 0; g < p.length; g += 16) {
		var j = o;
		var h = n;
		var f = m;
		var e = l;
		o = md5_ff(o, n, m, l, p[g + 0], 7, -680876936);
		l = md5_ff(l, o, n, m, p[g + 1], 12, -389564586);
		m = md5_ff(m, l, o, n, p[g + 2], 17, 606105819);
		n = md5_ff(n, m, l, o, p[g + 3], 22, -1044525330);
		o = md5_ff(o, n, m, l, p[g + 4], 7, -176418897);
		l = md5_ff(l, o, n, m, p[g + 5], 12, 1200080426);
		m = md5_ff(m, l, o, n, p[g + 6], 17, -1473231341);
		n = md5_ff(n, m, l, o, p[g + 7], 22, -45705983);
		o = md5_ff(o, n, m, l, p[g + 8], 7, 1770035416);
		l = md5_ff(l, o, n, m, p[g + 9], 12, -1958414417);
		m = md5_ff(m, l, o, n, p[g + 10], 17, -42063);
		n = md5_ff(n, m, l, o, p[g + 11], 22, -1990404162);
		o = md5_ff(o, n, m, l, p[g + 12], 7, 1804603682);
		l = md5_ff(l, o, n, m, p[g + 13], 12, -40341101);
		m = md5_ff(m, l, o, n, p[g + 14], 17, -1502002290);
		n = md5_ff(n, m, l, o, p[g + 15], 22, 1236535329);
		o = md5_gg(o, n, m, l, p[g + 1], 5, -165796510);
		l = md5_gg(l, o, n, m, p[g + 6], 9, -1069501632);
		m = md5_gg(m, l, o, n, p[g + 11], 14, 643717713);
		n = md5_gg(n, m, l, o, p[g + 0], 20, -373897302);
		o = md5_gg(o, n, m, l, p[g + 5], 5, -701558691);
		l = md5_gg(l, o, n, m, p[g + 10], 9, 38016083);
		m = md5_gg(m, l, o, n, p[g + 15], 14, -660478335);
		n = md5_gg(n, m, l, o, p[g + 4], 20, -405537848);
		o = md5_gg(o, n, m, l, p[g + 9], 5, 568446438);
		l = md5_gg(l, o, n, m, p[g + 14], 9, -1019803690);
		m = md5_gg(m, l, o, n, p[g + 3], 14, -187363961);
		n = md5_gg(n, m, l, o, p[g + 8], 20, 1163531501);
		o = md5_gg(o, n, m, l, p[g + 13], 5, -1444681467);
		l = md5_gg(l, o, n, m, p[g + 2], 9, -51403784);
		m = md5_gg(m, l, o, n, p[g + 7], 14, 1735328473);
		n = md5_gg(n, m, l, o, p[g + 12], 20, -1926607734);
		o = md5_hh(o, n, m, l, p[g + 5], 4, -378558);
		l = md5_hh(l, o, n, m, p[g + 8], 11, -2022574463);
		m = md5_hh(m, l, o, n, p[g + 11], 16, 1839030562);
		n = md5_hh(n, m, l, o, p[g + 14], 23, -35309556);
		o = md5_hh(o, n, m, l, p[g + 1], 4, -1530992060);
		l = md5_hh(l, o, n, m, p[g + 4], 11, 1272893353);
		m = md5_hh(m, l, o, n, p[g + 7], 16, -155497632);
		n = md5_hh(n, m, l, o, p[g + 10], 23, -1094730640);
		o = md5_hh(o, n, m, l, p[g + 13], 4, 681279174);
		l = md5_hh(l, o, n, m, p[g + 0], 11, -358537222);
		m = md5_hh(m, l, o, n, p[g + 3], 16, -722521979);
		n = md5_hh(n, m, l, o, p[g + 6], 23, 76029189);
		o = md5_hh(o, n, m, l, p[g + 9], 4, -640364487);
		l = md5_hh(l, o, n, m, p[g + 12], 11, -421815835);
		m = md5_hh(m, l, o, n, p[g + 15], 16, 530742520);
		n = md5_hh(n, m, l, o, p[g + 2], 23, -995338651);
		o = md5_ii(o, n, m, l, p[g + 0], 6, -198630844);
		l = md5_ii(l, o, n, m, p[g + 7], 10, 1126891415);
		m = md5_ii(m, l, o, n, p[g + 14], 15, -1416354905);
		n = md5_ii(n, m, l, o, p[g + 5], 21, -57434055);
		o = md5_ii(o, n, m, l, p[g + 12], 6, 1700485571);
		l = md5_ii(l, o, n, m, p[g + 3], 10, -1894986606);
		m = md5_ii(m, l, o, n, p[g + 10], 15, -1051523);
		n = md5_ii(n, m, l, o, p[g + 1], 21, -2054922799);
		o = md5_ii(o, n, m, l, p[g + 8], 6, 1873313359);
		l = md5_ii(l, o, n, m, p[g + 15], 10, -30611744);
		m = md5_ii(m, l, o, n, p[g + 6], 15, -1560198380);
		n = md5_ii(n, m, l, o, p[g + 13], 21, 1309151649);
		o = md5_ii(o, n, m, l, p[g + 4], 6, -145523070);
		l = md5_ii(l, o, n, m, p[g + 11], 10, -1120210379);
		m = md5_ii(m, l, o, n, p[g + 2], 15, 718787259);
		n = md5_ii(n, m, l, o, p[g + 9], 21, -343485551);
		o = safe_add(o, j);
		n = safe_add(n, h);
		m = safe_add(m, f);
		l = safe_add(l, e)
	}
	return Array(o, n, m, l)
}
function md5_cmn(h, e, d, c, g, f) {
	return safe_add(bit_rol(safe_add(safe_add(e, h), safe_add(c, f)), g), d)
}
function md5_ff(g, f, k, j, e, i, h) {
	return md5_cmn((f & k) | ((~f) & j), g, f, e, i, h)
}
function md5_gg(g, f, k, j, e, i, h) {
	return md5_cmn((f & j) | (k & (~j)), g, f, e, i, h)
}
function md5_hh(g, f, k, j, e, i, h) {
	return md5_cmn(f ^ k ^ j, g, f, e, i, h)
}
function md5_ii(g, f, k, j, e, i, h) {
	return md5_cmn(k ^ (f | (~j)), g, f, e, i, h)
}
function core_hmac_md5(c, f) {
	var e = str2binl(c);
	if (e.length > 16) {
		e = core_md5(e, c.length * chrsz)
	}
	var a = Array(16), d = Array(16);
	for (var b = 0; b < 16; b++) {
		a[b] = e[b] ^ 909522486;
		d[b] = e[b] ^ 1549556828
	}
	var g = core_md5(a.concat(str2binl(f)), 512 + f.length * chrsz);
	return core_md5(d.concat(g), 512 + 128)
}
function safe_add(a, d) {
	var c = (a & 65535) + (d & 65535);
	var b = (a >> 16) + (d >> 16) + (c >> 16);
	return (b << 16) | (c & 65535)
}
function bit_rol(a, b) {
	return (a << b) | (a >>> (32 - b))
}
function str2binl(d) {
	var c = Array();
	var a = (1 << chrsz) - 1;
	for (var b = 0; b < d.length * chrsz; b += chrsz) {
		c[b >> 5] |= (d.charCodeAt(b / chrsz) & a) << (b % 32)
	}
	return c
}
function binl2hex(c) {
	var b = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
	var d = "";
	for (var a = 0; a < c.length * 4; a++) {
		d += b.charAt((c[a >> 2] >> ((a % 4) * 8 + 4)) & 15)
				+ b.charAt((c[a >> 2] >> ((a % 4) * 8)) & 15)
	}
	return d
}
function binl2b64(d) {
	var c = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
	var f = "";
	for (var b = 0; b < d.length * 4; b += 3) {
		var e = (((d[b >> 2] >> 8 * (b % 4)) & 255) << 16)
				| (((d[b + 1 >> 2] >> 8 * ((b + 1) % 4)) & 255) << 8)
				| ((d[b + 2 >> 2] >> 8 * ((b + 2) % 4)) & 255);
		for (var a = 0; a < 4; a++) {
			if (b * 8 + a * 6 > d.length * 32) {
				f += b64pad
			} else {
				f += c.charAt((e >> 6 * (3 - a)) & 63)
			}
		}
	}
	return f
};